home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Utilities / DOpus / DOpus5-Arexx / Playmidi.dopus5 < prev    next >
Encoding:
Text File  |  1998-04-10  |  1.9 KB  |  86 lines

  1. /* Script Arexx pour jouer des fichiers midi dans dopus5
  2.    (C)1998 Raistlin 
  3.    Version 1.0
  4.  
  5.    Usage :   DOpus5:ARexx/Playmidi.dopus5 {f} {Qp}
  6.              No flags
  7. */
  8.  
  9. parse arg '"' file '"' portname .
  10.  
  11. if portname='' then
  12.    portname='DOPUS.1'
  13. address value portname
  14.  
  15. cuthere=lastpos('/',file)
  16. if cuthere=0 then
  17.    cuthere=pos(':',file)
  18. name=""substr(file,cuthere+1)""
  19.  
  20. if ~show('l','rexxsupport.library') then
  21.    call addlib('rexxsupport.library',0,-30)
  22.  
  23. options results
  24.  
  25. lister query source
  26. Handle = result
  27.  
  28. lister set handle busy on
  29.  
  30. address command 'GM:'
  31. address command 'Run >T:gmplay <NIL: gm:GMPLAY <NIL: >PIPE:gm-output' file
  32.  
  33. lister set handle newprogress info bar abort
  34. lister set handle newprogress title 'Playing 'name' ...'
  35. lister set handle newprogress info 'Loading Instruments ...'
  36.  
  37. open('temp','T:gmplay','r')
  38.  
  39. process = readln('temp')
  40. parse var process '[CLI ' process ']'
  41. close('temp')
  42. call delete('T:gmplay')
  43.  
  44. buffer=''
  45. open('gm','PIPE:gm-output','r')
  46. timer=0
  47. measure=0
  48. percent=0
  49. ended=0
  50.  
  51. do until ended > 0
  52.    buffer=buffer||readch('gm',15)
  53.    new=verify(buffer,'%','m')
  54.    ended=pos('Finished',buffer)
  55.  
  56.    lister query handle abort
  57.    if result then do
  58.       address command 'Break' process 'C'
  59.       lister clear handle progress
  60.         lister set handle busy off
  61.         call close('gm')
  62.       exit
  63.    end
  64.  
  65.    if new >0 then do                    /* check for new line */
  66.       line=left(buffer,new-1)  
  67.         buffer=substr(buffer,new+1)
  68.  
  69.         pos0=pos('Time',line)
  70.       pos1=pos('Meas',line)
  71.         pos2=pos('Perc',line)
  72.  
  73.       if pos0 + pos1 + pos2 ~= 0 then do
  74.          timer   = substr(line,pos0+5,5)
  75.             measure = substr(line,pos1+8,pos2-pos1-8)
  76.             percent = substr(line,pos2+11,3)
  77.  
  78.             lister set handle newprogress info 'Playing measure 'measure'   Time: 'timer
  79.             lister set handle newprogress bar 100 percent
  80.         end
  81.    end
  82. end
  83.  
  84. call close('gm')
  85. lister clear handle progress
  86. lister set handle busy off